package com.xinnet.core.validate;

import javax.validation.ConstraintValidatorContext;


/**
 * 定义共通的Validator。
 * 
 * @author System Integrator Corp.
 */
public class Validator {
	
	/**
	 * 接口的验证方法
	 * */
	public boolean isValid(Object value,
			ConstraintValidatorContext constraintContext) {

		if (valid(value)) {
			return true;
		} else {
			constraintContext.disableDefaultConstraintViolation();
			constraintContext
					.buildConstraintViolationWithTemplate(getMessage())
					.addConstraintViolation();
			return false;
		}
	}

	public boolean valid(Object value) {
		return false;
	}
	/**
	 * 未通过验证时,提示错误信息
	 * */
	public String getMessage() {
		return "";
	}
}
